package top.ffhome.quartz.task;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import top.ffhome.framework.socket.WebSocketServer;

@Slf4j
@Component("socketTask")
public class SocketTask {
    /**
     * socket推送的pid
     */
    private static final String WEBSOCKET_PID = "common_001";

    public void sendSocket() {
        log.info("socketTask: {}", System.currentTimeMillis());
        JSONObject message = new JSONObject();
        message.put("name", "Test");
        message.put("time", DateUtil.now());
        String messageStr = message.toJSONString();
        WebSocketServer.sendSocketMessage(messageStr, WEBSOCKET_PID);
    }
}
